<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="AAuto" /> 
<title>HTML事件触发器</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="maincontent">
<h1>HTML事件触发器</h1>
 <div class="desc">参考:<a href="../libraries/std/web/html.html"></a> <a href="webform.html">创建web窗体</a> <a href="html.html#dom">什么是DOM</a> </div>
 <div>
   <h2>HTML事件</h2>
  <p>&nbsp;</p>
  <p><strong>1、基本语法：</strong><br />
  </p>
  <pre>var doc = wb.getDoc()
var ok = doc.attachEvent(&quot;HTML事件名称&quot;,IDispatch接口对象 )</pre>
  <p><br />
    <strong>2、函数说明：</strong><br />
    <br />
  请参考: <a href="getele.html#getDoc">wb.getDoc()</a><br />
  文档对象提从attachEvent方法,可以为指定的事件绑定一个Dispatch接口对象作为事件触发器.<br />
  使用<a href="../libraries/kernel/com/interface.html#IDispatch">com.ImplInterface</a>创建IDispatch接口.<br />
  </p>
  <p>可选的HTML事件名称请参考:<a href="http://www.ecranesoft.com/doc/html/dhtml/events.html">http://www.ecranesoft.com/doc/html/dhtml/events.html</a></p>
  <p><strong>3、调用示例：
  </strong></p>
  </p>
  <pre>
//创建web窗体的代码省略,请在快手中点击新建web窗体

//打开目标网站
wb.go("http://www.ecranesoft.com/")
//显示窗体
winform.show(true) 
 
io.open()

htmlEvent = <span class="bluefont">com.ImplInterface</span>( 
   function(event){
   	  io.print("点击坐标", event.screenX,event.screenY )
   	  io.print("触发节点", event.srcElement.innerText )
   } 
) 
var doc = wb.waitDoc()//等待并返回document对象
<span class="bluefont">doc.attachEvent</span>("onclick",htmlEvent)

//进入消息循环
win.loopMessage();</pre>
  <p><br />
    HTML事件触发时会传递一个event参数,该参考的成员请参考下面的网页:</p>
  <p><a href="http://www.ecranesoft.com/doc/html/dhtml/objects/obj_event.html">http://www.ecranesoft.com/doc/html/dhtml/objects/obj_event.html</a></p>
 </div>
</div></body>
</html>